<?php

/**
 * Created by PhpStorm.
 * User: 王琳
 * Date: 2015/12/15
 * Time: 14:17
 */
/*#报告管理模型#*/
class ReportModel extends Model{

    //显示市区级报告列表
    public function show_report_list($data){

        //$data['level'] = 2;
        $result = D("health_report")->field("rpt_id,rpt_name,area_name,rpt_time,garden_name,is_over")->where($data)->select();
        //判断结果集是否为空
        if(!empty($result)){
            return $result;
        }else{
            return false;
        }
    }
    /*市级报告 筛选*/
    public function city_screen($area,$is_over){
        $data['area_name'] = $area;
        $data['is_over'] = $is_over;
        $reports = D("health_report")->where($data)->select();
        if(!empty($reports)){
            return $reports;
        }else{
            return array();
        }
    }

    /*统计完成和未完成的份数*/
    public function statistics_count($area_name,$is_over,$level = 2){
        $data['is_over'] = $is_over;
        $data['area_name'] = $area_name;
        $data['level'] = $level;
        $num = D("health_report")->field("count(*) as count_number")->where($data)->select();
        if(!empty($num)){
            return $num;
        }else{
            return 0;
        }
    }

    /*获得完成和未完成的数据*/
    public function get_report_data($area_name,$is_over,$level = 2){
        $data['is_over'] = $is_over;
        $data['area_name'] = $area_name;
        $data['level'] = $level;
        $reports = D("health_report")->where($data)->select();
        if(!empty($reports)){
            return $reports;
        }
        return array();
    }


    /*获取园名*/
    public function get_garden_names(){
        $data['level'] = 3;
        $arr = D("health_report")->field("distinct garden_name")->where($data)->select();
        if(!empty($arr)){
            return $arr;
        }
        return array();
    }

}